package com.ruoyi.system.controller.car4s_controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.car4s_domain.Car4sPartsInfo;
import com.ruoyi.system.service.car4s_service.ICar4sPartsInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 配件信息Controller
 * 
 * @author LK
 * @date 2024-06-29
 */
@RestController
@RequestMapping("/system/car_4s_parts_info")
public class Car4sPartsInfoController extends BaseController
{
    @Autowired
    private ICar4sPartsInfoService car4sPartsInfoService;

    /**
     * 查询配件信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:car_4s_parts_info:list')")
    @GetMapping("/list")
    public TableDataInfo list(Car4sPartsInfo car4sPartsInfo)
    {
        startPage();
        List<Car4sPartsInfo> list = car4sPartsInfoService.selectCar4sPartsInfoList(car4sPartsInfo);
        return getDataTable(list);
    }

    /**
     * 导出配件信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:car_4s_parts_info:export')")
    @Log(title = "配件信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Car4sPartsInfo car4sPartsInfo)
    {
        List<Car4sPartsInfo> list = car4sPartsInfoService.selectCar4sPartsInfoList(car4sPartsInfo);
        ExcelUtil<Car4sPartsInfo> util = new ExcelUtil<Car4sPartsInfo>(Car4sPartsInfo.class);
        util.exportExcel(response, list, "配件信息数据");
    }

    /**
     * 获取配件信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:car_4s_parts_info:query')")
    @GetMapping(value = "/{partsId}")
    public AjaxResult getInfo(@PathVariable("partsId") Long partsId)
    {
        return success(car4sPartsInfoService.selectCar4sPartsInfoByPartsId(partsId));
    }

    /**
     * 新增配件信息
     */
    @PreAuthorize("@ss.hasPermi('system:car_4s_parts_info:add')")
    @Log(title = "配件信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Car4sPartsInfo car4sPartsInfo)
    {
        return toAjax(car4sPartsInfoService.insertCar4sPartsInfo(car4sPartsInfo));
    }

    /**
     * 修改配件信息
     */
    @PreAuthorize("@ss.hasPermi('system:car_4s_parts_info:edit')")
    @Log(title = "配件信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Car4sPartsInfo car4sPartsInfo)
    {
        return toAjax(car4sPartsInfoService.updateCar4sPartsInfo(car4sPartsInfo));
    }

    /**
     * 删除配件信息
     */
    @PreAuthorize("@ss.hasPermi('system:car_4s_parts_info:remove')")
    @Log(title = "配件信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{partsIds}")
    public AjaxResult remove(@PathVariable Long[] partsIds)
    {
        return toAjax(car4sPartsInfoService.deleteCar4sPartsInfoByPartsIds(partsIds));
    }
}
